/**
 * 辅助函数工具箱
 */

// 用于生成表格边框和内容的辅助函数
function printBoxedLog(messages) {
  const boxWidth =
    messages.reduce((max, msg) => Math.max(max, msg.length), 0) + 4;
  const border = "-".repeat(boxWidth + 8);

  console.log(border);
  messages.forEach((message) => {
    const padding = " ".repeat(boxWidth - message.length - 2);
    console.log(`| ${message}${padding}|`);
  });
  console.log(border);
}

module.exports = {
  printBoxedLog,
};
